<?php
/**
 * Framework.php is the core of WP Framework which defines the main class
 *
 * @package WP_Framework
 */

/**
 * class WPFramework - Main class loads all includes, adds/removes filters.
 * 
 * @since - 0.1
 */
class WPFramework {
	
	/**
	 * init() - Initialisation method which calls all other methods in turn.
	 *
	 * @since - 0.1
	 */
	function init() {		
		$framework = new WPFramework;
		$framework->constants();
		$framework->includes();
		$framework->prep_work();
		
		do_action( 'framework_init' ); // Available hook: framework_init
		require_once( THEMELIB . '/core/pluggable.php' );
		register_widgets();
	}

	/**
	 * constants() - defines WP Framework Constants
	 *
	 * @since - 0.3
	 * @todo - test all constants for all possible outcomes
	 */
	function constants() {
		define( 'THEMEASSETS', TEMPLATEPATH . '/assets' );
		define( 'THEMEDIR', TEMPLATEPATH ); // Framework theme dir
		define( 'THEMELIB', TEMPLATEPATH . '/library' ); // Framework library

		define( 'THEMEASSETS_DIR', get_bloginfo( 'template_directory' ) . '/assets' ); // file path to theme assets dir
		define( 'THEMEASSETS_URI', get_bloginfo( 'template_url' ) . '/assets' ); // URI for theme assets dir

		// URI Path to core theme asset folders
		define( 'THEMECSS', THEMEASSETS_URI . '/css' );
		define( 'THEMEIMG', THEMEASSETS_URI . '/images' );
		define( 'THEMEJS', THEMEASSETS_URI . '/js' );
/*
		// Child theme Dir/URI paths (needs testing)
		define( 'CHILDTHEME_DIR', get_stylesheet_directory() );
		define( 'CHILDTHEME_URI', get_stylesheet_directory_uri() );
*/
	}
	
	/**
	 * includes() - A function to include all files from a directory path
	 *
	 * @since - 0.3
	 */
	function includes() {
		require_once( THEMELIB . '/core/hooks.php' );
		require_once( THEMELIB . '/core/general-template.php' );
		require_once( THEMELIB . '/core/loop.php' );
		require_once( THEMELIB . '/core/comments.php' );
		require_once( THEMELIB . '/core/wp-compat.php' );
		require_once( THEMELIB . '/core/helpers.php' );
	}
		
	function prep_work(){
		add_action( 'framework_init', 'get_theme_functions' ); // include theme.php from theme assets dir if file exist
		
		add_action( 'framework_hook_header', 'get_header' ); // get_header() - loads header.php
		add_action( 'framework_hook_sidebar', 'get_sidebar' ); // get_sidebar() - loads sidebar.php
		add_action( 'framework_hook_footer', 'get_footer' ); // get_footer() - loads footer.php
		
		add_action( 'framework_hook_title', 'framework_title' );
		add_action( 'framework_hook_head', 'framework_head' );
		add_action( 'framework_hook_head', 'comment_reply_js' );
		add_action( 'framework_hook_menu', 'framework_menu' );
		add_filter( 'wp_page_menu', 'framework_menu_ulclass' );
		add_filter( 'the_generator', 'framework_version', 1 ); // framework_version() - gives you the ability to hide or show WordPress/WP Framework version. (hides by default)
		add_filter( 'post_gallery', 'post_gallery_filter' ); // stops [gallery] styles from being added to the page. making html invalid
		// loop
		add_action( 'framework_hook_before_loop', 'framework_page_title' );
		add_action( 'framework_hook_after_loop', 'framework_after_loop' );
		
		// comments
		add_action( 'framework_hook_comments_open', 'framework_comment_navigation' );
		add_action( 'framework_hook_comments_close', 'framework_comment_navigation' );
	}
}
?>